# uncompyle6 version 3.2.3
# Python bytecode 3.6 (3379)
# Decompiled from: Python 3.6.8 |Anaconda custom (64-bit)| (default, Feb 21 2019, 18:30:04) [MSC v.1916 64 bit (AMD64)]
# Embedded file name: helpers\exceptions\__init__.py
__author__ = "sanyi"
import json


class ExtendedException(Exception):
    HTTP_ERROR_CODE = "500 Internal Server Error"
    __type__ = "exception"

    def __init__(self, *args, **kwargs):
        super(ExtendedException, self).__init__()
        self.args = args
        self.kwargs = kwargs
        try:
            self.accept_languages = kwargs["accept_languages"]
            del kwargs["accept_languages"]
        except KeyError:
            self.accept_languages = (("en", 1),)

        try:
            self.exception_context = kwargs["exception_context"]
            del kwargs["exception_context"]
        except KeyError:
            self.exception_context = None

    def to_dict(self):
        return dict(
            __type__=self.__type__,
            __class__=self.__class__.__name__,
            args=self.args,
            kwargs=self.kwargs,
        )

    def to_plain_text_api_response(self):
        return repr(self)

    def to_obj_api_response(self):
        return self.to_dict()

    def __str__(self):
        return self.__class__.__name__ + ":" + (json.dumps(self.to_dict(), indent=2))

    def __repr__(self):
        return self.__str__()
